
/*
 * @Author: 于建霞
 * @Date: 2020-11-Tu 03:30:26
 * @Last Modified by:   于建霞 
 * @Last Modified time: 2020-11-Tu 03:30:26 
 * 
 * * @description: 迎接弹框
 */

import React, { useState, useCallback, useRef, useEffect } from 'react';
import { Modal, Button, Card, Form, Input, Select, Row, Col, DatePicker, message } from 'antd';
import ProTable from '@ant-design/pro-table';
import { useRequest, useBoolean } from '@umijs/hooks';
import { getVipEntry, greetVip, promitEntryVip } from '../../service';
import { getScanResults } from '../../scanParsing.js';
import { formatFlightNo } from '@/utils/pagesGeneralMethods'; // 页面通用方法
import styles from './index.less';
import moment from 'moment';

import AddEntourage from '../addEntourage'; //随行人员添加

const { Option } = Select;
const { TextArea } = Input;
const { confirm } = Modal;
let scanResultsObj = {};
const VipGreet = (props) => {
    const { form: { getFieldDecorator, validateFields, setFieldsValue, getFieldValue, resetFields },
        vipGreetVisible,
        setVipGreetVisible, 
        scanCode, // 扫码枪扫描结果
        setScanCode, //设置扫码结果的函数
        openType, //区别点击迎接按钮打开（click） 还是 扫描枪扫描进入（scan）;
        selectData, //出发和到达航站数据
        vipRoomObj, //选中的贵宾室
        reloadTable, //父组件的reload函数
        paxTypeData, //旅客类型
        selectRow, //父组件勾选的数据
        scanCodeToEntourage, //用于随行添加的扫码
        handleGreetAddFlag, //用于父组件监听这个迎接框的添加随行人员的显示
    } = props;
    // 设置查询结果输入框的启用和禁用
    const { state: inputDisable, setTrue, setFalse } = useBoolean(true);
    // 设置查询条件输入框的启用和禁用
    const { state: conditionsDisable, setTrue:conditionsDisableTrue, setFalse:conditionsDisableFalse } = useBoolean(false);
    // 提取旅客的启用和禁用
    const { state: extractDisable, setTrue:setExtractTrue, setFalse:setExtractFalse } = useBoolean(false);
    const [state, setstate] = useState({});
    const [passengerData, setPassengerData] = useState({}); // 提取的旅客数据
    const [checkedAlongs, setCheckedAlongs] = useState([]); // 选中的要添加的随行人员
    const [addEntourageVisible, setAddEntourageVisible] = useState(false)// 添加随行人员弹框
    // const [operateType, setOperateType] = useState(null)// 迎接，拒绝的类型

    // 页面请求start
    // 根据扫描或输入提取旅客信息
    const { run:getVipInfoFun, loading:getVipInfoLoading } = useRequest((flightInfo)=> getVipEntry(flightInfo),{
        manual: true,
        onSuccess: (data) => {
            if(!data || JSON.stringify(data) == '{}') {
                resetTable();
                return message.error('未查询到旅客信息');  
            }
            if(data.memo){ //如果有备注就提示
                Modal.info({
                    title: `${data.paxName} 旅客`,
                    content: (
                        <div>
                            <p>旅客喜好：</p>
                            <p>旅客备注：{data.memo}</p>
                        </div>
                    ),
                    onOk() {},
                });
            }
            setPassengerData(data);
            setExtractTrue();
            conditionsDisableTrue();
            setFieldsValue({
                tktNo : data.tktNo, //票号
                paxName : data.paxName, //旅客姓名
                dstCityAirp : data.dst, //到达航站三字码
                flightStatus : data.flightStatus ? data.flightStatus : 'N', //航班状态
                // entryFlag : data.entryFlag, //准入标志
                // alongs : data.alongs, //随行人数
                // paxTypeCode : data.paxTypeCode, //旅客类型
                status : data.status, //旅客状态
                entryTime : data.entryTime, //迎接时间
                leaveTime : data.leaveTime, //送别时间
                passengerLike : data.passengerLike, //旅客喜好
                memo : data.memo, //备注信息
            });
            // 调用重复进厅提示的接口
            repeatTipsFun({
                paxIds:data.paxId,
                vipRoomId:vipRoomObj?.id,
            });
        },
        onError: err => {
            resetTable();
            console.log('err', err)
        }
    })
    // 重置页面数据
    const resetTable = () =>{
        setExtractFalse();
        conditionsDisableFalse();
        setPassengerData({});
        setCheckedAlongs([]);
        setFieldsValue({
            tktNo : '', //票号
            paxName :  '', //旅客姓名
            dstCityAirp :  '', //到达航站三字码
            flightStatus :  '', //航班状态
            // entryFlag : data.entryFlag, //准入标志
            // alongs : data.alongs, //随行人数
            // paxTypeCode : data.paxTypeCode, //旅客类型
            status :  '', //旅客状态
            entryTime :  '', //迎接时间
            leaveTime : '', //送别时间
            passengerLike :  '', //旅客喜好
            memo :  '', //备注信息
        });
    }
    // 迎接旅客重复进厅
    const { run:promitEntryVipFun,} = useRequest((vipInfo)=> promitEntryVip(vipInfo),{
        manual: true,
        onSuccess: (data) => {
            if (data?.msg) {
                Modal.info({
                    content: (
                        <div>
                            <p>{data?.msg}</p>
                        </div>
                    ),
                    onOk() {
                        // 点击迎接时提示
                        // submitFun();
                    },
                });
            }
            // 点击迎接时提示
            // else{
            //     submitFun();
            // }
        }
    })
    // 迎接旅客
    const { run:greetVipInfoFun, loading:greetvipInfoLoading } = useRequest((vipInfo)=> greetVip(vipInfo),{
        manual: true,
        onSuccess: (data) => {
            message.success('操作成功');
            setPassengerData({});
            setCheckedAlongs([]);
            setVipGreetVisible(false);
            reloadTable();
        }
    })
    // 页面请求end

    // 扫描之后自动提取旅客
    useEffect(() => {
        if (openType === 'scan') { //扫码枪进入
            if (scanCode) {
                scanResultsObj = getScanResults(scanCode);
                // scanResultsObj = getScanResults('M1DANGZHENFENG        EMXELTV PEKCTU3U 8882 250H051K0022 12B>1030MM0E87621391676140NI513701199007200055');
                // console.log('扫描结果', scanResultsObj)
                // scanResults = {
                //     paxName:"", // 旅客姓名
                //     flightNo:"", // 航班号
                //     serialNo:"", // 值机序号
                //     orgCityAirp:"", // 起始航站三字码
                //     dstCityAirp:"", // 到达航站三字码
                //     filghtDate:"", // 航班日期
                //     ticketNo:"", //票号
                // }
                if (scanResultsObj) {
                   setFieldsValue({
                        bordCardCode2: scanCode,
                        tktNo : scanResultsObj.ticketNo, //票号
                        paxName : scanResultsObj.paxName, //旅客姓名
                        flightNo : scanResultsObj.flightNo, //航班号
                        bordNo : scanResultsObj.serialNo, //值机序号
                        orgCityAirp : scanResultsObj.orgCityAirp, //起始航站三字码
                        dstCityAirp : scanResultsObj.dstCityAirp, //到达航站三字码
                        lclDptDate:moment(scanResultsObj.filghtDate) //航班日期
                    });
                    // 自动提取旅客数据
                    extract(); 
                }else{
                   message.error('非法条码');
                }
            }
        }
    }, [scanCode,openType])
    // 扫描之后传入的内容
    useEffect(() => {
        if (openType !== 'scan') { //点击进入
            if (selectRow.length !== 0) {
                setExtractTrue();
                conditionsDisableTrue();
                let initData = selectRow[0] || {};
                setPassengerData(initData);
                setFieldsValue({
                    bordCardCode2: scanCode, //登机牌条码
                    tktNo : initData.tktNo, //票号
                    paxName : initData.paxName, //旅客姓名
                    flightNo : initData.flightNo, //航班号
                    bordNo : initData.bordNo, //值机序号
                    orgCityAirp : initData.org, //起始航站三字码
                    dstCityAirp : initData.dst, //到达航站三字码
                    lclDptDate:moment(initData.lclDptDate || initData.flightDate), //航班日期
                    flightStatus:initData.flightStatus ? initData.flightStatus : 'N', // 航班状态
                    // entryFlag:initData.entryFlag, //准入标志
                    // paxTypeCode:initData.paxTypeCode, //旅客类型
                    status:initData.status, //旅客状态
                    entryTime:initData.entryTime, //迎接时间
                    leaveTime:initData.leaveTime, //送别时间
                    passengerLike:initData.passengerLike, //旅客喜好
                    memo:initData.memo, //备注信息
                });
            }else{
                if(JSON.stringify(passengerData) == '{}') {
                    setExtractFalse();
                    conditionsDisableFalse();
                }
            }
        }
        setFieldsValue({
            vipRoom:vipRoomObj?.roomName
        });
    }, [scanCode,vipRoomObj,openType,selectRow])

    // 设置关闭之后再打开的填充值
    useEffect(() => {
        if (openType !== 'scan' && selectRow.length !== 0){
            let initData = selectRow[0] || {};
            // 重复进厅提示
            if (vipGreetVisible) {
                // 调用重复进厅提示的接口
                repeatTipsFun();
            }
            conditionsDisableTrue();
            setPassengerData(initData);
            setFieldsValue({
                bordCardCode2: scanCode, //登机牌条码
                tktNo : initData.tktNo, //票号
                paxName : initData.paxName, //旅客姓名
                flightNo : initData.flightNo, //航班号
                bordNo : initData.bordNo, //值机序号
                orgCityAirp : initData.org, //起始航站三字码
                dstCityAirp : initData.dst, //到达航站三字码
                lclDptDate:moment(initData.lclDptDate || initData.flightDate), //航班日期
                flightStatus:initData.flightStatus ? initData.flightStatus : 'N', // 航班状态
                // entryFlag:initData.entryFlag, //准入标志
                // paxTypeCode:initData.paxTypeCode, //旅客类型
                status:initData.status, //旅客状态
                entryTime:initData.entryTime, //迎接时间
                leaveTime:initData.leaveTime, //送别时间
                passengerLike:initData.passengerLike, //旅客喜好
                memo:initData.memo, //备注信息
            });
        }
    }, [selectRow,vipGreetVisible,openType]);

    // 调用重复进厅提示的接口
    const repeatTipsFun = (obj = {
        paxIds:passengerData?.paxId,
        vipRoomId:vipRoomObj?.id}) => {
        promitEntryVipFun(obj)
    }

    // 提取旅客数据
    const extract = () => {
        validateFields(['lclDptDate', 'flightNo', 'bordNo', 'orgCityAirp'], (err, values) => {
            if (!err) {
                let params = {
                    ...values, 
                    lclDptDate:moment(values.lclDptDate).format('YYYY-MM-DD'),
                    tktNo:getFieldValue('tktNo'),
                    paxName:getFieldValue('paxName'),
                    dstCityAirp:getFieldValue('dstCityAirp'),
                    bordNo:Number(values.bordNo)+'',  //消除多余的0占位符
                };
                getVipInfoFun(params);
                // setVipGreetVisible(false);
            }
        });
    }

    // 迎接 type 1-迎接 ，2-送别，3-拒绝  
    const handleOk = (type) => {
        validateFields(['paxTypeCode'],(err, values) => {
            if (!err) {
                if(JSON.stringify(passengerData) == '{}' ){
                    return message.error('请先提取旅客信息');
                }
                let greetInfoObj = {
                        "paxTypeCode":getFieldValue('paxTypeCode').toString(),  //贵宾室旅客类别编码
                        "std":passengerData.std, // 起飞时间
                        "status":type, // 状态 1-迎接 ，2-送别，3-拒绝
                        "flightNo":getFieldValue('flightNo'), //航班号
                        "orgCityAirp":getFieldValue('orgCityAirp'), // 起始航站三字码
                        "dstCityAirp":getFieldValue('dstCityAirp'),// 到达航站三字码
                        "bordNo":Number(getFieldValue('bordNo'))+'', //值机序号
                        "lclDptDate": moment(getFieldValue('lclDptDate')).format('YYYY-MM-DD'), //航班日期
                        "bordStatus":passengerData.fltBordStatus, //航班登机状态
                        "paxStatus":getFieldValue('status'), // 旅客状态
                        // "alongs":getFieldValue('alongs') , //随行人数
                        "paxName":getFieldValue('paxName'), //旅客姓名
                        "memo":getFieldValue('memo') , //备注信息
                        "paxId":passengerData.paxId, //旅客Id
                        "tktNo":getFieldValue('tktNo'), //票号
                        "flightStatus":passengerData.flightStatus ? passengerData.flightStatus : 'N', //航班状态
                        "phoneNo":passengerData.phoneNo, //联系方式
                        "pnrRef":passengerData.pnrRef, //pnr
                        "idNo":passengerData.idNo, //证件号
                        "flightType":passengerData.flightType, //航班类型 D-国内 I-国际
                        // "acmpIds": type == 1 ? idsArr.join(',') : "",
                        "acmpList": type == 1 ? JSON.stringify(checkedAlongs) : ""
        
                    };
                if (type == 1) {
                    confirm({
                        title: '提示',
                        content: Number(passengerData.alongs) == 0 ? 
                        `贵宾旅客${passengerData.paxName}，未添加随行人员，是否添加随行人员？`:
                        `已为贵宾旅客${passengerData.paxName}，添加${Number(passengerData.alongs)}名随行人员${passengerData.acmpNames}，是否还需添加随行人员？`,
                        okText:"是",
                        cancelText:"否",
                        onOk() {
                            addEntourageFun();
                        },
                        onCancel() {
                            greetVipInfoFun(greetInfoObj);
                        },
                      });
        
                }else{
                    greetVipInfoFun(greetInfoObj);
                }
                // 点击迎接时提示
                // // 调用重复进厅提示接口
                // promitEntryVipFun({
                //     paxIds:passengerData?.paxId,
                //     vipRoomId:vipRoomObj?.id
                // })
            }
        });
    }
    // 提交迎接接口
    // const submitFun = () => {
    //     let greetInfoObj = {
    //             "paxTypeCode":getFieldValue('paxTypeCode').toString(),  //贵宾室旅客类别编码
    //             "std":passengerData.std, // 起飞时间
    //             "status":operateType, // 状态 1-迎接 ，2-送别，3-拒绝
    //             "flightNo":getFieldValue('flightNo'), //航班号
    //             "orgCityAirp":getFieldValue('orgCityAirp'), // 起始航站三字码
    //             "dstCityAirp":getFieldValue('dstCityAirp'),// 到达航站三字码
    //             "bordNo":Number(getFieldValue('bordNo'))+'', //值机序号
    //             "lclDptDate": moment(getFieldValue('lclDptDate')).format('YYYY-MM-DD'), //航班日期
    //             "bordStatus":passengerData.fltBordStatus, //航班登机状态
    //             "paxStatus":getFieldValue('status'), // 旅客状态
    //             // "alongs":getFieldValue('alongs') , //随行人数
    //             "paxName":getFieldValue('paxName'), //旅客姓名
    //             "memo":getFieldValue('memo') , //备注信息
    //             "paxId":passengerData.paxId, //旅客Id
    //             "tktNo":getFieldValue('tktNo'), //票号
    //             "flightStatus":passengerData.flightStatus ? passengerData.flightStatus : 'N', //航班状态
    //             "phoneNo":passengerData.phoneNo, //联系方式
    //             "pnrRef":passengerData.pnrRef, //pnr
    //             "idNo":passengerData.idNo, //证件号
    //             "flightType":passengerData.flightType, //航班类型 D-国内 I-国际
    //             // "acmpIds": operateType == 1 ? idsArr.join(',') : "",
    //             "acmpList": operateType == 1 ? JSON.stringify(checkedAlongs) : ""

    //         };
    //     if (operateType == 1) {
    //         confirm({
    //             title: '提示',
    //             content: Number(passengerData.alongs) == 0 ? 
    //             `贵宾旅客${passengerData.paxName}，未添加随行人员，是否添加随行人员？`:
    //             `已为贵宾旅客${passengerData.paxName}，添加${Number(passengerData.alongs)}名随行人员${passengerData.acmpNames}，是否还需添加随行人员？`,
    //             okText:"是",
    //             cancelText:"否",
    //             onOk() {
    //                 addEntourageFun();
    //             },
    //             onCancel() {
    //                 greetVipInfoFun(greetInfoObj);
    //             },
    //           });

    //     }else{
    //         greetVipInfoFun(greetInfoObj);
    //     }
    // }
    // 取消
    const handleCancel = () => {
        conditionsDisableFalse();
        setPassengerData({});
        setCheckedAlongs([]);
        setScanCode&&setScanCode('');
        setVipGreetVisible(false);
        resetFields();
    }
    // 输入登机牌条码
    const onChangebordCardCode = (e) => {
        if (!e.target.value) {
            setFieldsValue({
                tktNo : '', //票号
                paxName : '', //旅客姓名
                flightNo : '', //航班号
                bordNo : '', //值机序号
                orgCityAirp : '', //起始航站三字码
                dstCityAirp : '', //到达航站三字码
                lclDptDate: ''//航班日期
            });
        }
        scanResultsObj = getScanResults(e.target.value);
        if (scanResultsObj) {
            setFieldsValue({
                tktNo : scanResultsObj.ticketNo, //票号
                paxName : scanResultsObj.paxName, //旅客姓名
                flightNo : scanResultsObj.flightNo, //航班号
                bordNo : scanResultsObj.serialNo, //值机序号
                orgCityAirp : scanResultsObj.orgCityAirp, //起始航站三字码
                dstCityAirp : scanResultsObj.dstCityAirp, //到达航站三字码
                lclDptDate:moment(scanResultsObj.filghtDate) //航班日期
            });
        }
    }
    // 添加随行
    const addEntourageFun = () =>{
        if(JSON.stringify(passengerData) == '{}' ){
            return message.error('请先提取旅客信息');
        }
        setPassengerData({...passengerData});
        setAddEntourageVisible(true);
        handleGreetAddFlag&&handleGreetAddFlag(true);
    }
    let columns1 = [
        {
            title: 'PNR',
            dataIndex: 'pnrRef',
            hideInSearch: true,
            width: 130
        },
        {
            title: '旅客姓名',
            order: 2,
            filters: false,
            dataIndex: 'paxName',
            width: 120,
        },
        {
          title: '航班状态',
          dataIndex: 'flightStatus',
          hideInSearch:true,
          width: 90,
          filters: false,
          valueEnum: {
            null: {
              text: '正常',
            },
            'D': {
              text: '延误',
            },
            'C': {
              text: '取消',
            },
            'N': {
              text: '正常',
            },
          },
        },
        {
            title: '航班日期',
            dataIndex: 'lclDptDate',
            order: 4,
            hideInTable: true,
            width: 150,
            renderFormItem: (_, { ...rest }) => {
                return (
                    <DatePicker
                        showTime={{ format: 'YYYY-MM-DD' }}
                        style={{ width: '100%' }}
                        format='YYYY-MM-DD'
                        {...rest}
                    />
                );
            },
        },
        {
            title: '航班号',
            dataIndex: 'flightNo',
            key: 'flightNo',
            width: 130,
            order: 5,
            renderFormItem: (_, { defaultRender, ...rest }) => {
                return <Input
                {...rest}
                onChange={e => {
                  e.target.value = formatFlightNo(e.target.value);
                  rest.onChange(e.target.value)
                }}
                allowClear maxLength={6} placeholder="3U" />;
            },
        },
        {
            title: '起飞时间',
            hideInSearch: true,
            dataIndex: 'std',
            width: 180
        },
        {
            title: '登机口',
            hideInSearch: true,
            dataIndex: 'gate',
            width: 130
        },
        {
            title: '始发站',
            order: 3,
            dataIndex: 'org',
            width: 200,
            renderFormItem: (_, { ...rest }, form) => {
                return (
                  <Select
                    allowClear={true}
                    showSearch
                    placeholder='请选择'
                    defaultActiveFirstOption={false}
                    showArrow={false}
                    filterOption={true}
                    optionFilterProp="children"
                    notFoundContent={null}
                    {...rest}
                  >
                    {
                      selectData && selectData.map((v, i) => {
                        return (
                          <Option key={v.CITY3CODE} value={v.CITY3CODE}>{v.CITYNAME}-{v.CITY3CODE}</Option>
                        )
                      })
                    }
                  </Select>
                );
              }
        },
        {
            title: '目的地',
            hideInSearch: true,
            dataIndex: 'dst',
            width: 130
        },
        {
            title: '航线',
            hideInSearch: true,
            dataIndex: 'fltRoute',
            width: 130
        },
        // {
        //     title: '登机牌条码',
        //     dataIndex: 'bordCardCode2',
        //     order: 1,
        //     width: 130
        // },
        {
            title: '操作',
            valueType: 'option',
            width: 80,
            fixed: 'left',
            align: "center",
            render: (text, row, _, action) => [
                <Button type="link" onClick={() => delAddItemFun(row)}>
                    删除
            </Button>
            ],
        }
    ];
    // 删除添加随行人员列表项
    const delAddItemFun = (row) => {
        setCheckedAlongs([...checkedAlongs].filter(item => item.paxId !== row.paxId));
    }
    return (
        <>
        <Modal
            title="迎接旅客"
            visible={vipGreetVisible}
            maskClosable={false}
            destroyOnClose={true}
            onCancel={handleCancel}
            width="80%"
            footer={
                <>
                    <Button onClick={handleCancel}>取消</Button>
                    <Button loading={greetvipInfoLoading} onClick={() => handleOk(3)}>拒绝</Button>
                    <Button loading={greetvipInfoLoading} onClick={() => handleOk(1)}>迎接</Button>
                    <Button type="primary" onClick={addEntourageFun}>
                        随行人员
                    </Button>
                </>
            }
        >
            <Form layout="vertical">
                {/* 第一块，贵宾室，登机牌条码 */}
                <Row gutter={24}>
                    <Col span={8}>
                        <Form.Item label="贵宾室：" style={{ marginBottom: "4px" }}>
                            {getFieldDecorator('vipRoom', 
                            // {
                            //     rules: [{ required: true, message: '请选择贵宾室' }],
                            // }
                            )(
                                <Input disabled placeholder="请选择贵宾室" />
                            )}
                        </Form.Item>
                    </Col>
                    <Col span={8}>
                        <Form.Item label="登机牌条码：" style={{ marginBottom: "4px" }}>
                            {getFieldDecorator('bordCardCode2', 
                            // {
                            //     rules: [{ required: true, message: '请输入登机牌条码' }],
                            // }
                            )(
                                <Input onBlur={onChangebordCardCode} disabled={conditionsDisable} allowClear placeholder="请输入登机牌条码" />
                            )}
                        </Form.Item>
                    </Col>
                </Row>
                {/* 提取旅客数据 */}
                <Card
                    title="提取旅客数据"
                    style={{ width: '100%', height: "200" }}
                    hoverable={true}
                    className={styles.smsModal}
                    headStyle={{ backgroundColor: "#FAFAFA" }}
                    bodyStyle={{ padding: 12 }}>
                    {/* 第一行 */}
                    <Row gutter={24}>
                        <Col span={8}>
                            <Form.Item label="票号：" style={{ marginBottom: "4px" }}>
                                {getFieldDecorator('tktNo')(
                                    <Input placeholder="请输入票号"  disabled={conditionsDisable}/>
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={8}>
                            <Form.Item label="旅客姓名：" style={{ marginBottom: "4px" }}>
                                {getFieldDecorator('paxName')(
                                    <Input placeholder="请输入旅客姓名"  disabled={conditionsDisable}/>
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={8}>
                            <Form.Item label="航班号：" style={{ marginBottom: "4px" }}>
                                {getFieldDecorator('flightNo', {
                                    rules: [{ required: true, message: '请输入航班号' }],
                                })(
                                    <Input onChange={e => {
                                        e.target.value = formatFlightNo(e.target.value);
                                      }} maxLength={6} placeholder="请输入航班号"  disabled={conditionsDisable}/>
                                )}
                            </Form.Item>
                        </Col>
                    </Row>
                    {/* 第二行 */}
                    <Row gutter={24}>
                        <Col span={8}>
                            <Form.Item label="值机序号：" style={{ marginBottom: "4px" }}>
                                {getFieldDecorator('bordNo', {
                                    rules: [{ required: true, message: '请输入值机序号' }],
                                })(
                                    <Input placeholder="请输入值机序号"  disabled={conditionsDisable}/>
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={8}>
                            <Form.Item label="始发地：" style={{ marginBottom: "4px" }}>
                                {getFieldDecorator('orgCityAirp', {
                                    rules: [{ required: true, message: '请选择始发地' }],
                                })(
                                    <Select
                                        allowClear={true}
                                        showSearch
                                        disabled={conditionsDisable}
                                        placeholder='请选择'
                                        defaultActiveFirstOption={false}
                                        showArrow={false}
                                        filterOption={true}
                                        optionFilterProp="children"
                                        notFoundContent={null}
                                    >
                                        {
                                        selectData && selectData.map((v, i) => {
                                            return (
                                            <Option key={v.CITY3CODE} value={v.CITY3CODE}>{v.CITYNAME}-{v.CITY3CODE}</Option>
                                            )
                                        })
                                        }
                                    </Select>
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={8}>
                            <Form.Item label="目的地：" style={{ marginBottom: "4px" }}>
                                {getFieldDecorator('dstCityAirp')(
                                    <Select
                                        allowClear={true}
                                        showSearch
                                        placeholder='请选择'
                                        disabled={conditionsDisable}
                                        defaultActiveFirstOption={false}
                                        showArrow={false}
                                        filterOption={true}
                                        optionFilterProp="children"
                                        notFoundContent={null}
                                    >
                                        {
                                        selectData && selectData.map((v, i) => {
                                            return (
                                            <Option key={v.CITY3CODE} value={v.CITY3CODE}>{v.CITYNAME}-{v.CITY3CODE}</Option>
                                            )
                                        })
                                        }
                                    </Select>
                                )}
                            </Form.Item>
                        </Col>
                    </Row>
                    {/* 第三行 */}
                    <Row gutter={24} type="flex" justify="space-between" align="bottom">
                        <Col span={8}>
                            <Form.Item label="航班日期：" style={{ marginBottom: "4px" }}>
                                {getFieldDecorator('lclDptDate',{
                                    // initialValue: scanResultsObj.filghtDate ? moment(scanResultsObj.filghtDate) : moment(),
                                    rules: [{ required: true, message: '请输入航班日期' }],
                                })(
                                    <DatePicker
                                        style={{ width: '100%' }}
                                        format="YYYY-MM-DD"
                                        allowClear={false}
                                        disabled={conditionsDisable}
                                    />
                                )}
                            </Form.Item>
                        </Col>

                        <Col span={8} offset={8}>
                            <div style={{ textAlign: "right", paddingBottom: "12px" }}>
                                <Button type="primary" disabled={extractDisable} onClick={extract} loading={getVipInfoLoading}>提取旅客</Button>
                            </div>
                        </Col>
                    </Row>
                </Card>
                {/* 旅客信息 */}
                <Card
                    title="旅客信息"
                    style={{ width: '100%', height: "200" }}
                    hoverable={true}
                    style={{ marginTop: "30px" }}
                    className={styles.smsModal}
                    headStyle={{ backgroundColor: "#FAFAFA" }}
                    bodyStyle={{ padding: 12, }}
                >
                    {/* 第一行 */}
                    <Row gutter={24}>
                        <Col span={8}>
                            <Form.Item label="航班状态：" style={{ marginBottom: "4px" }}>
                                {getFieldDecorator('flightStatus', 
                                // {rules: [{ required: true, message: '请输入航班状态' }],}
                                )(
                                    // <Input disabled={inputDisable} placeholder="请选择航班状态" />
                                    <Select
                                        allowClear={true}
                                        showSearch
                                        disabled={inputDisable} 
                                        placeholder='请选择航班状态'
                                        defaultActiveFirstOption={false}
                                        showArrow={false}
                                        filterOption={true}
                                        optionFilterProp="children"
                                        notFoundContent={null}
                                    >
                                        <Option value='N'>正常</Option>
                                        <Option value='D'>延误</Option>
                                        <Option value='C'>取消</Option>
                                    </Select>
                                )}
                            </Form.Item>
                        </Col>
                        {/* <Col span={8}>
                            <Form.Item label="准入标志：" style={{ marginBottom: "4px" }}>
                                {getFieldDecorator('entryFlag', 
                                // {
                                //     rules: [{ required: true, message: '请输入准入标志' }],
                                // }
                                )(
                                    <Input disabled={inputDisable} placeholder="请输入准入标志" />
                                )}
                            </Form.Item>
                        </Col> */}
                        {/* <Col span={8}>
                            <Form.Item label="随行人数：" style={{ marginBottom: "4px" }}>
                                {getFieldDecorator('alongs', 
                                // {
                                //     rules: [{ required: true, message: '请输入随行人数' }],
                                // }
                                )(
                                    <Input placeholder="请输入随行人数" />
                                )}
                            </Form.Item>
                        </Col> */}
                        <Col span={8}>
                            <Form.Item label="旅客类型：" style={{ marginBottom: "4px" }}>
                                {getFieldDecorator('paxTypeCode', 
                                {
                                    initialValue:passengerData?.paxTypeCode ? passengerData?.paxTypeCode.split(',') : [],
                                    rules: [{ required: true, message: '请选择旅客类型' }],
                                }
                                )(
                                    <Select
                                        allowClear={true}
                                        mode="multiple"
                                        showSearch
                                        placeholder='请选择旅客类型'
                                        defaultActiveFirstOption={false}
                                        showArrow={false}
                                        filterOption={true}
                                        optionFilterProp="children"
                                        notFoundContent={null}
                                    >
                                        {
                                            paxTypeData && paxTypeData.map((v, i) => {
                                                return (
                                                <Option key={v.paxTypeCode} value={v.paxTypeCode}>{v.paxTypeName}</Option>
                                                )
                                            })
                                        }
                                    </Select>
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={8}>
                            <Form.Item label="旅客状态：" style={{ marginBottom: "4px" }}>
                                {getFieldDecorator('status', 
                                // {
                                //     rules: [{ required: true, message: '请输入旅客状态' }],
                                // }
                                )(
                                    <Select
                                        allowClear={true}
                                        showSearch
                                        disabled={inputDisable}
                                        placeholder='请选择旅客状态'
                                        defaultActiveFirstOption={false}
                                        showArrow={false}
                                        filterOption={true}
                                        optionFilterProp="children"
                                        notFoundContent={null}
                                    >
                                         <Option value="1">已迎接</Option>
                                         <Option value="2">已送别</Option>
                                         <Option value="3">已拒绝</Option>
                                         {/* <Option value="4">未迎接</Option> */}
                                    </Select>
                                )}
                            </Form.Item>
                        </Col>
                    </Row>
                    {/* 第二行 */}
                    <Row gutter={24}>
                        <Col span={8}>
                            <Form.Item label="迎接时间：" style={{ marginBottom: "4px" }}>
                                {getFieldDecorator('entryTime', 
                                // {
                                //     rules: [{ required: true, message: '请输入迎接时间' }],
                                // }
                                )(
                                    <Input disabled={inputDisable} placeholder="请输入迎接时间" />
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={8}>
                            <Form.Item label="送别时间：" style={{ marginBottom: "4px" }}>
                                {getFieldDecorator('leaveTime', 
                                // {
                                //     rules: [{ required: true, message: '请输入送别时间' }],
                                // }
                                )(
                                    <Input disabled={inputDisable} placeholder="请输入送别时间" />
                                )}
                            </Form.Item>
                        </Col>
                    </Row>
                    <Form.Item label="旅客喜好：" style={{ marginBottom: "4px" }}>
                        {getFieldDecorator('passengerLike', 
                        // {
                        //     rules: [{ required: true, message: '请输入旅客喜好' }],
                        // }
                        )(
                            <TextArea disabled={inputDisable} rows={2} placeholder="请输入旅客喜好" />
                        )}
                    </Form.Item>
                    <Form.Item label="备注信息：" style={{ marginBottom: "4px" }}>
                        {getFieldDecorator('memo', 
                        // {
                        //     rules: [{ required: true, message: '请输入备注信息' }],
                        // }
                        )(
                            <TextArea rows={2} placeholder="请输入备注信息" maxLength="200"/>
                        )}
                    </Form.Item>

                </Card>
            </Form>
            {/* 随行人员的表格 */}
            {
                checkedAlongs.length > 0  ? <ProTable
                options={false}
                size="small"
                dataSource={checkedAlongs}
                scroll={{ x: 1000, y: 300 }}
                headerTitle="添加随行人员列表"
                search={false}
                loading={false}
                pagination={false}
                rowKey="paxId"
                columns={columns1}
                rowSelection={false}
                tableAlertRender={false}
            /> : null
            }
        </Modal>
            {/* 添加随行人员 */}
        <AddEntourage {...{ 
            addEntourageVisible, 
            setAddEntourageVisible, 
            handleGreetAddFlag,
            addOrGreet:"greet",
            selectData,
            addEntourageSelectRow: [passengerData],
            checkedAlongs,
            setCheckedAlongs,
            scanCodeToEntourage,
            // dataSourceFlag:'scan'
         }} />
      </>
    )
}

export default Form.create()(VipGreet);